package com.usermanage.SecurityConfig;

import com.usermanage.beanParam.PermissionBean;
import lombok.Getter;
import lombok.Setter;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.List;
import java.util.Set;

/**
 * Created by 過客 on 2018/3/9
 */
@Setter
@Getter
public class UserDetail implements UserDetails{
    private String username;
    private String password;
    private String parent_id;  //父级组id
    private String group_id;    //组id
//    private String group_uuid;    //企业uuid
    private String company_id;    //企业id
    private String user_type;    //用户类型
    private String company_type;    //企业类型
    private List<PermissionBean> list;    //权限列表
    private Integer id;
    private  Set<GrantedAuthority> authorities;
    private  boolean accountNonExpired;

    private  boolean accountNonLocked;

    private  boolean credentialsNonExpired;

    private  boolean enabled;

    public UserDetail(Integer id,String username, String password,String user_type,Set<GrantedAuthority> authorities, boolean accountNonExpired, boolean accountNonLocked, boolean credentialsNonExpired, boolean enabled) {
        this.username = username;
        this.id = id;
        this.password = password;
        this.user_type = user_type;
        this.authorities = authorities;
        this.accountNonExpired = accountNonExpired;
        this.accountNonLocked = accountNonLocked;
        this.credentialsNonExpired = credentialsNonExpired;
        this.enabled = enabled;
    }
    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return authorities;
    }

    @Override
    public String getPassword() {
        return password;
    }

    @Override
    public String getUsername() {
        return username;
    }

    @Override
    public boolean isAccountNonExpired() {
        return accountNonExpired;
    }

    @Override
    public boolean isAccountNonLocked() {
        return accountNonLocked;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return credentialsNonExpired;
    }

    @Override
    public boolean isEnabled() {
        return enabled;
    }


}
